// 测试 Array Iterator

const names = [ '敖广' , '敖钦' , '熬闰' , '敖顺' ];

console.log( 'keys:' );
// Array.prototype.keys()
let iterator = names.keys();
console.log( iterator ); // Object [Array Iterator] {}

let x ;
do {
    // 迭代器的 next 方法返回 { value: ? , done: false | true }
    x = iterator.next();
    console.log( x );
} while( !x.done );

console.log( 'values:' );
// Array.prototype.values()
iterator = names.values();
do {
    x = iterator.next();
    console.log( x );
} while( !x.done );

console.log( 'entries:' );
// Array.prototype.entries()
iterator = names.entries();
do {
    x = iterator.next();
    console.log( x );
} while( !x.done );

console.log( '- '.repeat(25) );

const pandas = [
    {id: 1001 , name: '和和' , age: 5 } ,
    {id: 1002 , name: '美美' , age: 6 } ,
    {id: 2003 , name: '团团' , age: 4 } ,
    {id: 2004 , name: '圆圆' , age: 8 }
];

iterator = pandas.values();
do {
    x = iterator.next();
    console.log( x );
}while( !x.done );